<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>全排列</h2>
<script>
    let arr = ['123','132','321','123']
    let res = [...new Set(arr)]
    console.log(res)
    // let arr = ['a','b','c']

    var permute = function(nums) {
        const result = [];
        const len = nums.length;
        for (let i=0; i<len; i++) {
            d([nums[i]]);
        }
        return result;
        function d(arr) {
            if (arr.length === len) {
                result.push(arr);
            }
            for (let i=0; i<len; i++) {
                if (arr.includes(nums[i])) {
                    continue;
                }
                let temp = arr.slice();
                temp.push(nums[i]);
                d(temp);
            }
        }
    };

</script>
</body>
</html>
